<?php

/**
 *info:海亮报修模板
 * @author:yjj
 *time:2017-03-28
 */
class RepairhlMsgtpl extends BaseMsgtpl
{
    /**
     * 派单发送消息
     * @param array $manager 管理员ID
     * @param array $order 订单信息
     * @param array $accountId 账号ID
     * @return
     */
    public function autoOperateSendMsg($order, $manager, $accountId)
    {
        $wechatUserInfo = D('Wechat/WechatUser')->getInfo(array('user_id' => $manager), 'openid,subscribe,wechat_id');
        $url = C('site_url') . "/Repairhl/RepairhlManager/BeforeAsset/repair_id/" . $order['repair_id'] . "/order_id/" . $order['order_id'];
        if ($accountId == 93) {
            //青橄榄测试
            $template_id = 'I68v9XH_Mual7IMta7fMXTPWHFDC80my1TKEY6V5BOg';
        } else if ($accountId == 60) {
            //云感测试
            $template_id = '_hHj0eU1ZQ7yorFomzpQvFV21NxQj8S_bqolOO9sbBk';
        }

        //if($wechatUserInfo && $wechatUserInfo['subscribe']){
        if ($accountId == 1) {
            $info = array(
                'first' => array("value" => '您有新的派单，请即时指派！', 'color' => '#173177'),
                'keyword1' => array("value" => $order['project_child_name'], "color" => "#173177"),
                'keyword2' => array("value" => $order['community_name'] . $order['building_name'] . $order['floor_name'] . $order['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else {
            $info = array(
                'first' => array("value" => '您有新的派单，请即时指派！', 'color' => '#173177'),
                'keyword1' => array("value" => $order['real_name']),
                /*'keyword3' => array("value" => date('Y-m-d H:i:s',strtotime("+1 hour")),"color" => "#173177" ),*/
                'keyword2' => array("value" => $order['community_name'] . $order['building_name'] . $order['floor_name'] . $order['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $order['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        }

        $result = $this->wxObj->messageTpl($this->wechatInfo['appid'], $this->wechatInfo['appsecret'], $wechatUserInfo['openid'], $template_id, $info, $url);
        return $result;
        //}

        return false;
    }

    public function autoOperateToSendMsg($orderId, $Person, $accountId)
    {
        $wechatUserInfo = D('Wechat/WechatUser')->getInfo(array('user_id' => $Person), 'openid,subscribe,wechat_id');
        $order = D('RepairhlOrder')->where(array('order_id' => $orderId))->field('type,repair_id,order_id,real_name,community_name,building_name,floor_name,room_name,project_child_name')->find();
        $url = C('site_url') . "/Repairhl/RepairhlPerson/orderDetail/repair_id/" . $order['repair_id'] . "/order_id/" . $order['order_id'];
        if ($accountId == 93) {
            $template_id = 'I68v9XH_Mual7IMta7fMXTPWHFDC80my1TKEY6V5BOg';
        } else if ($accountId == 60) {
            //云感测试
            $template_id = '_hHj0eU1ZQ7yorFomzpQvFV21NxQj8S_bqolOO9sbBk';
        } else {
            $template_id = '';
        }
        //判断是否是公共报修
        if ($order['type'] == 2) {
            $order['project_child_name'] = $order['public_name'];
        }
        //if($wechatUserInfo && $wechatUserInfo['subscribe']){
        if ($accountId == 93) {
            $info = array(
                'first' => array("value" => '您有新的派单，请即时指派！', 'color' => '#173177'),
                'keyword1' => array("value" => $order['real_name'], "color" => "#173177"),
                'keyword2' => array("value" => $order['community_name'] . $order['building_name'] . $order['floor_name'] . $order['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else if ($accountId == 39) {
            $info = array(
                'first' => array("value" => '您有新的派单，请即时指派！', 'color' => '#173177'),
                'keyword1' => array("value" => $order['real_name']),
                'keyword2' => array("value" => $order['community_name'] . $order['building_name'] . $order['floor_name'] . $order['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $order['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else {
            $info = array(
                'first' => array("value" => '您有新的派单，请即时指派！', 'color' => '#173177'),
                'keyword1' => array("value" => $order['real_name']),
                /*'keyword3' => array("value" => date('Y-m-d H:i:s',strtotime("+1 hour")),"color" => "#173177" ),*/
                'keyword2' => array("value" => $order['community_name'] . $order['building_name'] . $order['floor_name'] . $order['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $order['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        }

        $result = $this->wxObj->messageTpl($this->wechatInfo['appid'], $this->wechatInfo['appsecret'], $wechatUserInfo['openid'], $template_id, $info, $url);
        return $result;
        //}

        return false;
    }

    /**
     * 方法参数可以自己修改，添加--manager给维修工派单推送消息
     * @param array $userData 用户信息
     * @param array $orderInfo 订单信息
     */
    public function orderConfirmSendMsg($orderId, $accountId, $repairworker_id)
    {
        $mOrder = D('RepairhlOrder');
        $orderInfo = $mOrder->getByOrderId($orderId);
        //维修工微信信息
        $wechatUserInfo = D('Wechat/WechatUser')->getInfo(array('user_id' => $repairworker_id), 'openid,subscribe');
        $url = C('site_url') . '/index.php?g=Repairhl&m=RepairhlWorker&a=workDetails&repair_id=' . $orderInfo['repair_id'] . '&order_id=' . $orderInfo['order_id'];
        //判断是否是公共报修
        if ($orderInfo['type'] == 2) {
            $orderInfo['project_child_name'] = $orderInfo['public_name'];
        }

        if ($wechatUserInfo['subscribe']) {
            if ($accountId == 93) {
                $array = array(
                    'first' => array("value" => '您有一条新的订单，请即时确认！', 'color' => '#173177'),
                    'keyword1' => array("value" => $orderInfo['real_name'], "color" => "#173177"),
                    'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                    'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                    'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
                );
            } else if ($accountId == 38) {
                $array = array(
                    'first' => array("value" => '您有一条新的订单，请即时确认！', 'color' => '#173177'),
                    'keyword1' => array("value" => $orderInfo['real_name']),
                    'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                    'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                    'keyword4' => array("value" => $orderInfo['project_child_name'], "color" => "#173177"),
                    'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
                );
            } else {
                $array = array(
                    'first' => array("value" => '您有一条新的订单，请即时确认！', 'color' => '#173177'),
                    'keyword1' => array("value" => $orderInfo['real_name']),
                    'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                    'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                    'keyword4' => array("value" => $orderInfo['project_child_name'], "color" => "#173177"),
                    'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
                );
            }


            if ($accountId == 93) {
                $template_id = 'I68v9XH_Mual7IMta7fMXTPWHFDC80my1TKEY6V5BOg';
            } else if ($accountId == 38) {
                $template_id = '0uoTPSXgcXoBssMdHuNaRmBUOQOUZOWzC2V_iQ5Bz5Y';
            } else if ($accountId == 60) {
                //云感测试
                $template_id = '_hHj0eU1ZQ7yorFomzpQvFV21NxQj8S_bqolOO9sbBk';
            }
            $result = $this->wxObj->messageTpl($this->wechatInfo['appid'], $this->wechatInfo['appsecret'], $wechatUserInfo['openid'], $template_id, $array, $url);
        }
        return $result;

    }

    /**
     * 方法参数可以自己修改，添加--维修工接单后，推送消息给用户
     * @param array $userData 用户信息
     * @param array $orderInfo 订单信息
     */
    public function orderToUserSendMsg($orderId, $accountId)
    {
        $mOrder = D('RepairhlOrder');
        $orderInfo = $mOrder->getByOrderId($orderId);
        //用户微信信息
        $wechatUserInfo = D('Wechat/WechatUser')->getInfo(array('user_id' => $orderInfo['user_id']), 'openid,subscribe');
        $url = C('site_url') . '/index.php?g=Repairhl&m=RepairhlPerson&a=historyDetails&repair_id=' . $orderInfo['repair_id'] . '&order_id=' . $orderInfo['order_id'];

        //判断是否是公共报修
        if ($orderInfo['type'] == 2) {
            $orderInfo['project_child_name'] = $orderInfo['public_name'];
        }

        if ($accountId == 93) {
            $array = array(
                'first' => array("value" => '您的维修订单已接单！', 'color' => '#173177'),
                'keyword1' => array("value" => $orderInfo['real_name'], "color" => "#173177"),
                'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else if ($accountId == 38) {
            $array = array(
                'first' => array("value" => '您的维修订单已接单！', 'color' => '#173177'),
                'keyword1' => array("value" => $orderInfo['real_name']),
                'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $orderInfo['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else {
            $array = array(
                'first' => array("value" => '您的维修订单已接单！', 'color' => '#173177'),
                'keyword1' => array("value" => $orderInfo['real_name']),
                'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $orderInfo['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        }


        if ($accountId == 93) {
            $template_id = 'I68v9XH_Mual7IMta7fMXTPWHFDC80my1TKEY6V5BOg';
        } else if ($accountId == 60) {
            //云感测试
            $template_id = '_hHj0eU1ZQ7yorFomzpQvFV21NxQj8S_bqolOO9sbBk';
        }
        $result = $this->wxObj->messageTpl($this->wechatInfo['appid'], $this->wechatInfo['appsecret'], $wechatUserInfo['openid'], $template_id, $array, $url);

        //}
        return $result;
    }

    /**
     * 订单完成处理 -- 订单完成推送消息给用户
     * @param array $userData
     * @param array $orderInfo
     */
    public function orderFinishSendMsg($orderId, $accountId)
    {
        $mOrder = D('RepairhlOrder');
        //查询当前订单的信息
        $orderInfo = $mOrder->getByOrderId($orderId);
        $wechatUserInfo = D('Wechat/WechatUser')->getInfo(array('user_id' => $orderInfo['user_id']), 'openid,subscribe');

        $url = C('site_url') . '/index.php?g=Repairhl&m=RepairhlPerson&a=historyDetails&repair_id=' . $orderInfo['repair_id'] . '&order_id=' . $orderInfo['order_id'];

        //判断是否是公共报修
        if ($orderInfo['type'] == 2) {
            $orderInfo['project_child_name'] = $orderInfo['public_name'];
        }

        if ($accountId == 93) {
            $array = array(
                'first' => array("value" => '您的维修订单已完成，请及时评价！', 'color' => '#173177'),
                'keyword1' => array("value" => $orderInfo['real_name'], "color" => "#173177"),
                'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else if ($accountId == 38) {
            $array = array(
                'first' => array("value" => '您的维修订单已完成！', 'color' => '#173177'),
                'keyword1' => array("value" => $orderInfo['real_name']),
                'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $orderInfo['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else {
            $array = array(
                'first' => array("value" => '您的维修订单已完成，请及时评价！', 'color' => '#173177'),
                'keyword1' => array("value" => $orderInfo['real_name']),
                'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $orderInfo['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        }

        if ($accountId == 93) {
            $template_id = 'I68v9XH_Mual7IMta7fMXTPWHFDC80my1TKEY6V5BOg';
        } else if ($accountId == 38) {
            $template_id = '0uoTPSXgcXoBssMdHuNaRmBUOQOUZOWzC2V_iQ5Bz5Y';
        } else if ($accountId == 60) {
            //云感测试
            $template_id = '_hHj0eU1ZQ7yorFomzpQvFV21NxQj8S_bqolOO9sbBk';
        }
        $result = $this->wxObj->messageTpl($this->wechatInfo['appid'], $this->wechatInfo['appsecret'], $wechatUserInfo['openid'], $template_id, $array, $url);

        return $result;
        //}
        return false;
    }

    /**
     * 订单取消处理 -- 维修工取消订单推送消息给用户
     * @param array $userData
     * @param array $orderInfo
     */
    public function orderCancelSendMsg($orderId, $accountId)
    {
        $mOrder = D('RepairhlOrder');
        //查询当前订单的信息
        $orderInfo = $mOrder->getByOrderId($orderId);
        $wechatUserInfo = D('Wechat/WechatUser')->getInfo(array('user_id' => $orderInfo['user_id']), 'openid,subscribe');
        $url = C('site_url') . '/index.php?g=Repairhl&m=RepairhlPerson&a=historyDetails&repair_id=' . $orderInfo['repair_id'] . '&order_id=' . $orderInfo['order_id'];

        //判断是否是公共报修
        if ($orderInfo['type'] == 2) {
            $orderInfo['project_child_name'] = $orderInfo['public_name'];
        }

        if ($accountId == 93) {
            $array = array(
                'first' => array("value" => '无法维修，订单已被取消，请联系维修主管或重新下单！', 'color' => '#173177'),
                'keyword1' => array("value" => $orderInfo['real_name'], "color" => "#173177"),
                'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else if ($accountId == 38) {
            $array = array(
                'first' => array("value" => '您的维修订单已取消！', 'color' => '#173177'),
                'keyword1' => array("value" => $orderInfo['real_name']),
                'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $orderInfo['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else {
            $array = array(
                'first' => array("value" => '无法维修，订单已被取消，请联系维修主管或重新下单！', 'color' => '#173177'),
                'keyword1' => array("value" => $orderInfo['real_name']),
                'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $orderInfo['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        }

        if ($accountId == 93) {
            $template_id = 'I68v9XH_Mual7IMta7fMXTPWHFDC80my1TKEY6V5BOg';
        } else if ($accountId == 38) {
            $template_id = '0uoTPSXgcXoBssMdHuNaRmBUOQOUZOWzC2V_iQ5Bz5Y';
        } else if ($accountId == 60) {
            //云感测试
            $template_id = '_hHj0eU1ZQ7yorFomzpQvFV21NxQj8S_bqolOO9sbBk';
        }
        $result = $this->wxObj->messageTpl($this->wechatInfo['appid'], $this->wechatInfo['appsecret'], $wechatUserInfo['openid'], $template_id, $array, $url);

        return $result;
        //}
        return false;
    }


    /**
     * 设置补偿金额推送消息给用户支付
     * @param array $userData
     * @param array $orderInfo
     */
    public function orderPaySendMsg($orderId, $accountId)
    {
        $mOrder = D('RepairhlOrder');
        //查询当前订单的信息
        $orderInfo = $mOrder->getByOrderId($orderId);
        $wechatUserInfo = D('Wechat/WechatUser')->getInfo(array('user_id' => $orderInfo['user_id']), 'openid,subscribe');
        $url = C('site_url') . '/index.php?g=Repairhl&m=RepairhlPerson&a=historyDetails&repair_id=' . $orderInfo['repair_id'] . '&order_id=' . $orderInfo['order_id'];

        //判断是否是公共报修
        if ($orderInfo['type'] == 2) {
            $orderInfo['project_child_name'] = $orderInfo['public_name'];
        }

        if ($accountId == 93) {
            $array = array(
                'first' => array("value" => '您的维修订单补贴金额已经设置，请及时支付！', 'color' => '#173177'),
                'keyword1' => array("value" => $orderInfo['real_name'], "color" => "#173177"),
                'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else if ($accountId == 38) {
            $array = array(
                'first' => array("value" => '您的维修订单已取消！', 'color' => '#173177'),
                'keyword1' => array("value" => $orderInfo['real_name']),
                'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $orderInfo['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else {
            $array = array(
                'first' => array("value" => '您的维修订单补贴金额已经设置，请及时支付！', 'color' => '#173177'),
                'keyword1' => array("value" => $orderInfo['real_name']),
                'keyword2' => array("value" => $orderInfo['community_name'] . $orderInfo['building_name'] . $orderInfo['floor_name'] . $orderInfo['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $orderInfo['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        }

        if ($accountId == 93) {
            $template_id = 'I68v9XH_Mual7IMta7fMXTPWHFDC80my1TKEY6V5BOg';
        } else if ($accountId == 38) {
            $template_id = '0uoTPSXgcXoBssMdHuNaRmBUOQOUZOWzC2V_iQ5Bz5Y';
        } else if ($accountId == 60) {
            //云感测试
            $template_id = '_hHj0eU1ZQ7yorFomzpQvFV21NxQj8S_bqolOO9sbBk';
        }
        $result = $this->wxObj->messageTpl($this->wechatInfo['appid'], $this->wechatInfo['appsecret'], $wechatUserInfo['openid'], $template_id, $array, $url);

        return $result;
        //}
        return false;
    }

    //订单状态发生改变时均推送消息给主管
    public function sendToManager($orderId, $manager, $accountId)
    {
        $wechatUserInfo = D('Wechat/WechatUser')->getInfo(array('user_id' => $manager), 'openid,subscribe,wechat_id');
        $order = D('RepairhlOrder')->where(array('order_id' => $orderId))->field('cut_off,status,type,repair_id,order_id,real_name,community_name,building_name,floor_name,room_name,project_child_name,bad_id')->find();
       // $url = C('site_url') . "/Repairhl/RepairhlPerson/orderDetail/repair_id/" . $order['repair_id'] . "/order_id/" . $order['order_id'];
        if ($accountId == 93) {
            $template_id = 'I68v9XH_Mual7IMta7fMXTPWHFDC80my1TKEY6V5BOg';
        } else if ($accountId == 60) {
            //云感测试
            $template_id = '_hHj0eU1ZQ7yorFomzpQvFV21NxQj8S_bqolOO9sbBk';
        } else {
            $template_id = '';
        }
        $up_img=M('RepairhlOrderImage')->where(array('order_id'=>$orderId,'type'=>1))->select();
        if ($order['status'] == 0) {
            $url = C('site_url') . "/Repairhl/RepairhlManager/BeforeAsset/repair_id/" . $order['repair_id'] . "/order_id/" . $order['order_id'];
            $words = '维修订单已取消!';
        }elseif (count($up_img)) {
            $words = '有一条收据凭证待审核，请及时到"已指派"订单中处理';
        } elseif ($order['cut_off'] == 1) {
            $words = '有维修工申请撤销订单，请在后台核查';
        }elseif ($order['status'] == 5) {
            $words = '有挂起的维修订单，请到后台电脑审核!';
        } elseif ($order['status'] == 4) {
            $words = '维修订单已接单!';
        } elseif ($order['status'] == 6) {
            $words = '维修订单已完成!';
        } elseif ($order['status'] == 7 && $order['bad_id']==1) {
            $url = C('site_url') . "/Repairhl/RepairhlManager/afterasset/repair_id/" . $order['repair_id'] . "/order_id/" . $order['order_id'];
            $words = '维修订单属人为损坏，请到"已指派"订单中设置金额';
        }


        //if($wechatUserInfo && $wechatUserInfo['subscribe']){
        if ($accountId == 93) {
            $info = array(
                'first' => array("value" => $words, 'color' => '#173177'),
                'keyword1' => array("value" => $order['real_name'], "color" => "#173177"),
                'keyword2' => array("value" => $order['community_name'] . $order['building_name'] . $order['floor_name'] . $order['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else if ($accountId == 38) {
            $info = array(
                'first' => array("value" => $words, 'color' => '#173177'),
                'keyword1' => array("value" => $order['real_name']),
                'keyword2' => array("value" => $order['community_name'] . $order['building_name'] . $order['floor_name'] . $order['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $order['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "点击查看详情！", "color" => "#173177"),
            );
        } else {
            $info = array(
                'first' => array("value" => $words, 'color' => '#173177'),
                'keyword1' => array("value" => $order['real_name']),
                'keyword2' => array("value" => $order['community_name'] . $order['building_name'] . $order['floor_name'] . $order['room_name'], "color" => "#173177"),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'keyword4' => array("value" => $order['project_child_name'], "color" => "#173177"),
                'remark' => array("value" => "海亮教育集团！", "color" => "#173177"),
            );
        }

        $result = $this->wxObj->messageTpl($this->wechatInfo['appid'], $this->wechatInfo['appsecret'], $wechatUserInfo['openid'], $template_id, $info, $url);
        return $result;

        return false;
    }

    /**
     * 维修工无法维修提交返修,发消息给用户
     * @param array $userData 用户信息
     * @param array $orderInfo 订单信息
     */
    /*public function backSendMessage($order,$accountId)
    {
        $mOrder = D('RepairOrder');
        $mUser = D('User');
        $orderInfo = $mOrder->getByPk($order['order_id']);
        $repairman = $mUser->getByPk($orderInfo['repairman_id']);
        $wechatUserInfo = D('Wechat/WechatUser')->getInfo(array('user_id'=>$orderInfo['user_id']), 'openid,subscribe');
        $url = C('site_url').'/index.php?g=base&m=repair&a=orderDetail&repairId='.$orderInfo['repair_id'].'&order_id='.$orderInfo['order_id'];
        if($wechatUserInfo['subscribe']) {

                $array = array(
                        'first' => array("value" => $orderInfo['real_name'].'，您的维修单已提交返修,请确认并重新下单。','color' => '#FF0000'),
                        'keyword2' => array("value" => $repairman['real_name'] ),
                        'keyword1' => array("value" => date("Y-m-d H:i:s"),"color" => "#173177"),
                        'remark' => array("value" => "请点击查看！","color" => "#173177"),
                );



            if($accountId == 2){
                $template_id = 'ervBp_BlUtHqKsaIw0qjmFz2KXy9J1tWCF5TIhW042Q';
            }elseif($accountId==5){
                $template_id = 'p_P3GalanUy8syyholudeTR3OB5hzEuEAz-w12D_lbQ';
            }elseif($accountId==6){
                $template_id = 'DAxDdnfAhywT-lfRTsaSGOQwd96g5RQnXMTigQknWCA';
            }elseif($accountId == 4){
                $template_id = 'k203JXlZ8F8SCYUIR3uH_HBL8Uq2aAMbAIv2N1r46ec';
            }elseif($accountId == 10){
                $template_id = 'A4NBwXw1VQmYDOBzCImVstEnwLG2tvbkztK8vbJkc-I';
            }elseif($accountId == 28){
                $template_id = 'Rf7JatKFZNlX-Fji4e2AmRwCvffF8bCsUxdnsHCHAZs';
            }elseif($accountId==3){
                $template_id = 'yI0d_ILucYN4r_4lfnqsvwUOPd94K7Se7rQkUScaEiU';
            }elseif($this->wechatInfo['account_id'] == 17){
                $template_id = 'qV44STOD0tpw_b2JHWrV7TsBk3uYdjpuCIYSp5gJqb4';
            }
            $this->wxObj->messageTpl($this->wechatInfo['appid'], $this->wechatInfo['appsecret'], $wechatUserInfo['openid'], $template_id, $array, $url);
        }

    }*/


}
